package com.hy.erp.inventory.service;

import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.interfaces.ICargoSpaceGroupDao;
import com.hy.erp.inventory.pojo.CargoSpaceGroup;
import com.hy.erp.inventory.pojo.interfaces.ICargoSpaceGroup;
import com.hy.erp.inventory.service.interfaces.ICargoSpaceGroupService;
/**
 * 
 * <ul>
 * <li>开发作者：李冰</li>
 * <li>设计日期：2010-10-13；时间：上午09:17:04</li>
 * <li>类型名称：CargoSpaceGroupService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
@ Name ( "cargoSpaceGroupService" )
@ Scope ( ScopeType.STATELESS )
@ Stateless


public class CargoSpaceGroupService  extends AbstractBusinessService < ICargoSpaceGroup > implements ICargoSpaceGroupService{


	private static final long serialVersionUID = -762387205430487427L;

	@Override
	public boolean addCargoSpaceGroup(ICargoSpaceGroup cargoSpaceGroup) {
		if ( null == cargoSpaceGroup)
		{
			return true ;
		}
		
		else
		{
			System.out
						.println ("ssssssssssssssssssssssffffffffffffffffhghhhhhhhhhhhhhhhhhhhhhh") ;


			ICargoSpaceGroupDao cargoSpaceGroupDao =
			                       ( ICargoSpaceGroupDao ) this
			                                          .getDao ( ICargoSpaceGroup.class ) ;
			
			return cargoSpaceGroupDao
			                .persist ( cargoSpaceGroup ) ;
		}
		
	}

	@Override
	public boolean modifyCargoSpaceGroup(ICargoSpaceGroup cargoSpaceGroup) {
		if ( ( null == cargoSpaceGroup )
			     || ( null == cargoSpaceGroup
			                                .getIdentifier ( ) )
			     || ( cargoSpaceGroup
			                        .getIdentifier ( )
			                        .trim ( )
			                        .length ( ) == 0 ) )
			{
				return true ;
			}
			else
			{
				ICargoSpaceGroupDao cargoSpaceGroupDao =
                    ( ICargoSpaceGroupDao ) this
                                       .getDao ( ICargoSpaceGroup.class ) ;
		
					
				if ( null == cargoSpaceGroup )
				{
					throw new ArchitectureFoundationException  (
					                                            "修改实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
				}
				
				
				return ( cargoSpaceGroupDao
				                  .merge ( cargoSpaceGroup ) != null ) ;
			}
		
	}

	@Override
	public Integer removeCargoSpaceGroup(String[] cargoSpaceGroupIds) {
		if ( ( null == cargoSpaceGroupIds )
			     || ( cargoSpaceGroupIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{
				ICargoSpaceGroupDao cargoSpaceGroupDao =
                    ( ICargoSpaceGroupDao ) this
                                       .getDao ( ICargoSpaceGroup.class ) ;
				return cargoSpaceGroupDao
				                .remove ( cargoSpaceGroupIds ) ;
			}
	}

	@ Override
	public String [ ] addCargoSpaceGroup (
											Object [ ] cargoSpaceGroup  )
	{


		if ( null == cargoSpaceGroup )
		{
			return null ;
		}

		else
		{

			ICargoSpaceGroupDao cargoSpaceGroupDao =
                ( ICargoSpaceGroupDao ) this
                                   .getDao ( ICargoSpaceGroup.class ) ;
			CargoSpaceGroup[] cargoSpaceGroups=new CargoSpaceGroup[cargoSpaceGroup.length];
			for(int i=0;i<cargoSpaceGroup.length;i++)
			{
				CargoSpaceGroup cargoSpaceGroup2=( CargoSpaceGroup ) cargoSpaceGroup[i];
				cargoSpaceGroups[i]=cargoSpaceGroup2;
			}
			
			

			return cargoSpaceGroupDao
								.persist  ( cargoSpaceGroups ) ;
		}
	
	}

	@ Override
	public String [ ] modifyCargoSpaceGroup (
												Object [ ] cargoSpaceGroup )
	{

		if ( null == cargoSpaceGroup )
		{
			return null ;
		}

		else
		{

			ICargoSpaceGroupDao cargoSpaceGroupDao =
                ( ICargoSpaceGroupDao ) this
                                   .getDao ( ICargoSpaceGroup.class ) ;
			CargoSpaceGroup[] cargoSpaceGroups=new CargoSpaceGroup[cargoSpaceGroup.length];
			for(int i=0;i<cargoSpaceGroup.length;i++)
			{
				CargoSpaceGroup cargoSpaceGroup2=( CargoSpaceGroup ) cargoSpaceGroup[i];
				cargoSpaceGroups[i]=cargoSpaceGroup2;
			}
			
			

			return cargoSpaceGroupDao
								.merge   ( cargoSpaceGroups ) ;
		}
	}
	

}
